/*
 * Copyright (C) 2025 Tsingteng MicroSystem
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @file rw_int.h
 * @brief 定义读卡模块内部使用的函数和结构
 */
#ifndef _RW_INT_H_
#define _RW_INT_H_

#include "nci_feature.h"
#if IS_FEATURE_ON(NCI_FEATURE_RW)

#include "nci_base.h"
#include "nfa_rw.h"

/**
 * @brief 重新选择当前标签
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他
 */
tNCI_STATUS rw_re_select();

/**
 * @brief 向卡片发送命令并获取响应
 *
 * @param[in] cmd 命令buf
 * @param[out] rsp 响应buf
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他
 */
tNCI_STATUS rw_transmit(tNCI_BUF *cmd, tNCI_BUF *rsp);

/**
 * @brief 执行卡片在位检测（不会获取RW锁，调用方需要获取读卡锁）
 *
 * @return 卡片在位返回NCI_STATUS_OK，反之返回其他错误码
 */
tNCI_STATUS rw_presence_check_no_lock();
/**
 * @brief 获取读卡锁
 *
 * @return 返回读卡模块锁的指针，不会为NULL
 */
tMUTEX *rw_get_mutex();

#if IS_FEATURE_ON(NCI_FEATURE_RW_EXT)
/**
 * @brief 设置读卡WatchDog线程状态（不会获取读卡锁，调用方需要获取读卡锁）
 *
 * @param is_paused 是否暂停WatchDog检测线程
 */
void rw_watch_dog_set_state_no_lock(bool is_paused);
#endif // IS_FEATURE_ON(NCI_FEATURE_RW_EXT)

#endif // IS_FEATURE_ON(NCI_FEATURE_RW)

#endif // _RW_INT_H_
